﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="InsertMovie.aspx.cs" Inherits="TheatreStaff_InsertMovie" %>
<%@ Register TagPrefix="custom" Namespace="myControls" %>

<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.Web.Configuration" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
  
    
    
//    if( Eval("ticketsold") >0)
    
//    { Response.Write("Hello");
//}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<script type="text/javascript">

    function displayCalendar() {
        var datePicker = document.getElementById('datePicker');
        datePicker.style.display = 'block';
    }
</script>
<script runat ="server" >
    protected void Clear(object sender, EventArgs e)
    {
        Label15.Text = string.Empty;
        Label16.Text = string.Empty;    
    }
    
    protected void Cancel(object sender, EventArgs e)
    {
        
        txtMovieTitleI.Text = string.Empty;
        txtMovieDirectorI.Text = string.Empty;
        chkShowingI.Checked = false;
        txtMovieDescriptionI.Text = string.Empty;
        txtMovieDurationI.Text = string.Empty;
        txtimagefnameI.Text = string.Empty;
        txtRatingI.Text = string.Empty;
        txtTrailersI.Text = string.Empty;
        txtTheatreDateReleasedI.Text = string.Empty;
        txtMaincastI.Text = string.Empty;
        Label15.Text = "";
        Label16.Text = "";
        ddlCategoryI.SelectedIndex = -1;       
        //grdMovie.DataBind();
    }
    protected void btnOk_Click(object sender, EventArgs e)
    {
        srcMovie.InsertParameters["TheatreId"].DefaultValue = lblId.Text;
        //grdMovie.DataBind();
        Label15.Text = "";
        Label16.Text = "";
    }
   
    protected void dtlSchedule_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
    {
        //grdMovie.DataBind();
        Label15.Text = "";
        Label16.Text = "";
    }
    
    protected void InsertMovie_Click(object sender, EventArgs e)
    {
        
        
        string connectionString;
        connectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlConnection con = new SqlConnection(connectionString);
        SqlConnection con1 = new SqlConnection(connectionString);
        SqlCommand cmd1 = new SqlCommand("INSERT Movie(CategoryId,MovieTitle,MovieDirector,Showing,MovieDescription,TheatreId,MovieDuration,imagefname,Rating,Trailers,TheatreDateReleased,maincast) values (@CategoryId,@MovieTitle,@MovieDirector,@Showing,@MovieDescription,@TheatreId,@MovieDuration,@imagefname,@Rating,@Trailers,@TheatreDateReleased,@maincast)", con1);
        SqlCommand cmd = new SqlCommand("SELECT MovieTitle,MovieDirector from Movie WHERE TheatreId=@TheatreId AND MovieTitle=@MovieTitle AND MovieDirector=@MovieDirector ", con);
        string ParamString = lblId.Text;
        Boolean Showing;
        Int32 RowCount;
        Boolean HasMovies;

        cmd.Parameters.AddWithValue("@TheatreId", ParamString);
        cmd.Parameters.AddWithValue("@MovieDirector", txtMovieDirectorI.Text);
        cmd.Parameters.AddWithValue("@MovieTitle", txtMovieTitleI.Text);

        using (con)
        {
            con.Open();
            SqlDataReader Reader = cmd.ExecuteReader();

            if (Reader.HasRows)
            {
                Label16.Text = "";
                Label15.Text = "The movie " + txtMovieTitleI.Text + " already exist in the database!";
                
                //lblCheck.Text = string.Empty;
                //ClientScript.RegisterClientScriptBlock(ClientScript.GetType(), "Focus", "<script language='JavaScript' 'showInsert();'/>");
               
                HasMovies = true;

            }
            else
            {
                HasMovies = false;

            }
        }
        using (con1)
        {
            con1.Open();
            if (HasMovies == false)
            {
                if (chkShowingI.Checked)
                {
                    Showing = true;

                }
                else
                {
                    Showing = false;
                }
      
                cmd1.Parameters.AddWithValue("@CategoryId", ddlCategoryI.SelectedValue);
                cmd1.Parameters.AddWithValue("@MovieTitle", txtMovieTitleI.Text);
                cmd1.Parameters.AddWithValue("@MovieDirector", txtMovieDirectorI.Text);
                cmd1.Parameters.AddWithValue("@Showing", Showing);
                cmd1.Parameters.AddWithValue("@MovieDescription", txtMovieDescriptionI.Text);
                cmd1.Parameters.AddWithValue("@TheatreId", lblId.Text);
                cmd1.Parameters.AddWithValue("@MovieDuration", txtMovieDurationI.Text);
                cmd1.Parameters.AddWithValue("@imagefname", txtimagefnameI.Text);
                cmd1.Parameters.AddWithValue("@Rating", txtRatingI.Text);
                cmd1.Parameters.AddWithValue("@Trailers", txtTrailersI.Text);
                cmd1.Parameters.AddWithValue("@TheatreDateReleased",DateTime.Parse(txtTheatreDateReleasedI.Text));
                cmd1.Parameters.AddWithValue("@maincast", txtMaincastI.Text);
                RowCount = cmd1.ExecuteNonQuery();
                ddlCategoryI.SelectedIndex = -1;
                txtMovieTitleI.Text = string.Empty;
                txtMovieDirectorI.Text = string.Empty;
                chkShowingI.Checked = false;
                txtMovieDescriptionI.Text = string.Empty;
                txtMovieDurationI.Text = string.Empty;
                txtimagefnameI.Text = string.Empty;
                txtRatingI.Text = string.Empty;
                txtTrailersI.Text = string.Empty;
                txtTheatreDateReleasedI.Text = string.Empty;
                txtMaincastI.Text = string.Empty;

                //if (RowCount > 0)
                //{
                Label15.Text = "";
                Label16.Text = "The Movie " + txtMovieTitleI.Text + " has been added sucessfully!";
                    //lblCorrect.Visible = true;
                  
                
                //}
            }
            
        }
        //grdMovie.DataBind();
    }
    void Page_Load()
    {
        if (!Page.IsPostBack)
            //grdMovie.SelectedIndex = 0;
        Label15.Text = string.Empty;
        Label16.Text = string.Empty;
    }
</script>
<script type="text/javascript">
    function showInsert() {
        var divInsert = document.getElementById('divInsert');
        divInsert.style.display = 'block';
    }
    function MM_preloadImages() { //v3.0
        var d = document; if (d.images) {
            if (!d.MM_p) d.MM_p = new Array();
            var i, j = d.MM_p.length, a = MM_preloadImages.arguments; for (i = 0; i < a.length; i++)
                if (a[i].indexOf("#") != 0) { d.MM_p[j] = new Image; d.MM_p[j++].src = a[i]; } 
        }
    }
    function MM_findObj(n, d) { //v4.01
        var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
            d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
        }
        if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
        for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
        if (!x && d.getElementById) x = d.getElementById(n); return x;
    }
    function MM_swapImage() { //v3.0
        var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
            if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
    }
    function MM_swapImgRestore() { //v3.0
        var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
    }
</script>
<%--This below code from the website:http://ramanisandeep.wordpress.com/2008/11/07/hide-an-aspnet-label-control-after-a-few-seconds/--%>
<script type="text/javascript">
    self.setInterval("changeValue1()", 4000);

    function changeValue1() {
        document.getElementById("Label15").innerText = "";

    }
    self.setInterval("changeValue()", 4000);
    function changeValue() {
        document.getElementById("Label16").innerText = "";

    }
</script>
 <style type="text/css">
        #datePicker
        {
            display:none;
            position:absolute;
            border:solid 2px black;
            background-color:white;
           
        }
    
    </style>
<style type="text/css">
#divDisplay
{
    border:solid 1px White;
    width:400px;
    padding:15px;
    margin:0px auto;
    text-align:center;
    border:1px solid #333;
}
.C
{
   color:#FFFFCC;
    font-size:larger;
    font-weight :bolder ;
}
.I
{
    color:red;
    font-size:larger;
    font-weight :bolder ;
}
#divInsert
{
    display:none;
    border:solid 1px black;
    width:500px;
    position:absolute;
    top:200px;
    left:100px;
    padding:10px;
    background-color:Silver;
    color:Black ;
}
html
{
  background-image:url('image/back.jpg'); 

    padding:10px;
    color:White;    
  
}
.content1
{
    margin:auto;
    width:850px;
}
.column
{
    float:left;
    width:648px;
}
.selectedRow
{
    background-color:Silver;
}

.content
{
    width:950px;
       margin:auto;
        height: 197px;
}

.link
{
  margin-left:350px; 
     font-weight:bold;
  font-size:large;  
    font-size:x-large;
}
.link2
{
  margin-left:50px; 
     font-weight:bold;
  font-size:large;  
    font-size:x-large;
}
a
{
 color: white;
 text-decoration:underline;
 font-weight:bold;

}
a:hover
{
 color: red; 
  text-decoration:none;
  font-weight:bold;

}
.join
{
   background-color:#0099FF;
  clip:auto;
  font-weight:bold;
  font-size:large;
}
.table2
{
 border-style:solid;
   border-color:Black;
   background-color:White;
   color:Black;  
   width:900px; 
}
.row
{
   background-color:Gray;
   color:White;
}
.ticket
{
   background-color:#CC0000;
color:White;

}
.center1
{
    padding-left:320px;
}
.ticket:hover
{
 color: black; 
  text-decoration:none;


}
.style1
{
    width: 509px;
}
.legend
{
    
     padding:5px;
    color:White;    
}  
.footer
{

     font-weight:bold;
  font-size:large;  

}
.ticket1
{
    padding-left:200px;
}
.view2
{
 padding-left:180px;  
}
.text
{
 font-weight:bold;
}
.button
{
 margin-left:250px;
}
.view3
{
    padding-left:120px;
}
.footer
{

   margin-top:250px;
}
.center
{
    padding-left:250px;
}
.cinema
{
    padding-left:590px;
}
  #footer {
    position:fixed;
        width: 100px;
        height: 100px;
        top:auto;
        right: 0;
        bottom: 0;
        left: 0;
      }
           .menu
{
 padding-left:180px;  

}
</style>


    <title>Movie Maintenance Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div class="content">
     <asp:Image ID="Image1" Width="1000" Height="130" ImageUrl="~/image/tdk-jun5-bannerbatmanexclusivo2.jpg" runat="server" /><br />
<asp:HyperLink ID="HyperLink14"  CssClass="link" NavigateUrl="~/Default.aspx" runat="server">Home</asp:HyperLink>
<asp:HyperLink ID="HyperLink1"  CssClass="link2" NavigateUrl="~/Session.aspx" runat="server">Session</asp:HyperLink> <asp:HyperLink ID="HyperLink2" CssClass="link2" NavigateUrl="~/Movie.aspx" runat="server">Movies</asp:HyperLink>
<asp:HyperLink ID="HyperLink3" CssClass="link2"  NavigateUrl="~/Price.aspx" runat="server">Prices</asp:HyperLink>

<br /> <br />

    <%--<td>&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp &nbsp&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp &nbsp&nbsp;&nbsp</td>--%>
    <%--<asp:Label ID="Label05" runat="server"  Text="Theatre" CssClass="cinema" Font-Bold="True" Font-Underline="True"></asp:Label>
        <asp:Label ID="Label2" runat="server"  ForeColor="Yellow"></asp:Label>
      
&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp &nbsp&nbsp;&nbsp 
          <asp:Label ID="Label005" runat="server" Text="UserName" Font-Bold="True"></asp:Label>    <asp:LoginName ID="LoginName1" runat="server" /> 
    &nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp<asp:LoginStatus ID="LoginStatus1" runat="server" ForeColor="#99CCFF" />--%>
    <table class="center1" >
        <tr>
            <td>
               <asp:Label ID="Label1111" runat="server" CssClass="menu"  Text="Theatre" Font-Bold="True" Font-Underline="True"></asp:Label>  
            </td>
            <td>
                 <asp:Label ID="Label2" runat="server"  ForeColor="Yellow"></asp:Label>
                 &nbsp;&nbsp;
            </td>
       <%-- </tr>
 </table> --%>
    <%--<td>&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp &nbsp&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp &nbsp&nbsp;&nbsp</td>--%>
<%--&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp&nbsp;&nbsp&nbsp&nbsp;&nbsp &nbsp&nbsp;&nbsp --%>
  <%--<table align="center" >
        <tr>--%>
            <td>
                <asp:Label ID="Label18" runat="server" Text="UserName" Font-Bold="True"></asp:Label>
                &nbsp;&nbsp;
            </td>
            <td>
                <asp:LoginName ID="LoginName1" runat="server" /> 
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </td>
            <td>
                 <asp:LoginStatus ID="LoginStatus1" runat="server" ForeColor="#99CCFF" />
                 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </td>
        </tr>
    </table>
<hr />
  <asp:Label ID="Label17" runat="server" Text="Maintain:" Font-Bold="True" Font-Size="Larger" Font-Underline="True"></asp:Label>
<asp:HyperLink ID="HyperLink4" runat="server" 
            NavigateUrl="~/TheatreStaff/Cinema.aspx" ForeColor="#FFCC99">[Cinemas]</asp:HyperLink>&nbsp;&nbsp;
    <asp:HyperLink ID="HyperLink5" runat="server"  ForeColor="#FFFF99" NavigateUrl="~/TheatreStaff/Movies.aspx">[Movies]</asp:HyperLink> &nbsp;
    <asp:HyperLink ID="HyperLink144" runat="server" NavigateUrl="~/TheatreStaff/Schedule.aspx" ForeColor="#FF9900">[Schedules]</asp:HyperLink>&nbsp;  
 <asp:HyperLink ID="HyperLink117" runat="server" NavigateUrl="~/TheatreStaff/Session.aspx" ForeColor="#FF6699">[Session Times]</asp:HyperLink>&nbsp;  
  <asp:HyperLink ID="HyperLink116" runat="server" NavigateUrl="~/TheatreStaff/SessionDates.aspx" ForeColor="#66FF66">[Session Date]</asp:HyperLink>&nbsp;   
 <asp:HyperLink ID="HyperLink115" runat="server" NavigateUrl="~/TheatreStaff/SpecialTickets.aspx" ForeColor="Aqua">[Specail Price]</asp:HyperLink>&nbsp;
 <asp:HyperLink ID="HyperLink107" runat="server" NavigateUrl="~/TheatreStaff/specialday.aspx" ForeColor="#CCFF33">[Special Ticket Pricing Days]</asp:HyperLink>&nbsp;  
    <asp:HyperLink ID="HyperLink6" runat="server" NavigateUrl="~/TheatreStaff/SalesReports.aspx" ForeColor="#CCFFFF">[Sales Report]</asp:HyperLink>&nbsp;
               <asp:HyperLink ID="HyperLink11" runat="server" NavigateUrl="~/TheatreStaff/AddNewUser.aspx" ForeColor="#66FF99">[Add New User]</asp:HyperLink>&nbsp; 
  <hr />
        <div class ="content1">
        <asp:Label ID="lblId" runat="server" Visible="false" ></asp:Label>
        
         <br />
           <h3><asp:Label ID="Label1" Text ="Insert Movie" runat="server" CssClass="center" ForeColor="#FFFF99" /></h3>
            <asp:BulletedList ID="BulletedList1" ForeColor="#FFFF99" runat="server">
            <%--<asp:ListItem> When you insert the release date, please insert folowing the format: mm/dd/yyyy</asp:ListItem>--%>
            <asp:ListItem Text ="Click 'Cancel' to return to the Movie Maintenance section" />
            </asp:BulletedList>
             
            <div class="column">
            <asp:Label ID="Label15" CssClass="I" runat="server"   ></asp:Label> 
                    <%--<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="CustomValidator"></asp:CustomValidator>--%>
                    <%--<asp:RequiredFieldValidator ID="reqError" runat="server" ControlToValidate="lblError" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>--%>
                    
             <asp:Label ID="Label16" CssClass="C" runat="server" ></asp:Label>
           
       
        <%--<a href="JavaScript:showInsert();">Insert Movie</a>
       </div>
          <%--<asp:LinkButton ID="LinkButton1" OnClick="CheckDelete" runat="server">Delete</asp:LinkButton>--%>
      
        <fieldset  >
            <legend  class ="legend"  >Insert Movie</legend>
            <table width="550px" >
                
                <tr>
                <td>
                    <asp:Label ID="Label3" runat="server" Text="Movie Title"></asp:Label>
                </td>
                <td>
                    <asp:TextBox
                    id="txtMovieTitleI"
                    Runat="server"/>
                </td>
                <td colspan ="2">
                  <asp:RequiredFieldValidator
                    id="reqMovieTitleI"
                    ControlToValidate="txtMovieTitleI"
                    Text="(Required)"
                    Runat="server" />  
                </td> 
                </tr>
                <tr>
                <td>
                    <asp:Label ID="Label4" runat="server" Text="Movie Category"></asp:Label>
                </td>
                <td>
                   <asp:DropDownList 
                    ID="ddlCategoryI" 
                     DataSourceID ="srcCategory" 
                     DataTextField ="MovieCategoryName" 
                     DataValueField ="MovieCategoryId" 
                     runat="server" AppendDataBoundItems ="true" >
                     <asp:ListItem Text ="Select" Value ="-1" />
                    </asp:DropDownList> 
                </td>
                <td colspan ="2">
                   <asp:RequiredFieldValidator
                        id="reqcategoryIDI"
                        ControlToValidate="ddlCategoryI" 
                        Text="(Required)" InitialValue ="-1"
                        Runat="server" />   
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="Label6" runat="server" Text="Movie Director"></asp:Label>
                </td>
                <td>
                     <asp:TextBox
                        id="txtMovieDirectorI"
                        Runat="server" />
                </td>
                <td colspan ="2">
                    <asp:RequiredFieldValidator
                        id="reqMovieDirectorI"
                        ControlToValidate="txtMovieDirectorI"
                        Text="(Required)"
                        Runat="server" />
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="Label7" runat="server" Text="Showing"></asp:Label>  
                </td>
                <td colspan="3">
                     <asp:CheckBox ID="chkShowingI"
                    runat="server" />
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="Label8" runat="server" Text="Movie Description"></asp:Label>
                </td>
                <td>
                    <asp:TextBox
                    id="txtMovieDescriptionI"
                    Runat="server" TextMode="MultiLine" />
                </td>
                <td colspan ="2">
                    <asp:RequiredFieldValidator
                    id="reqMovieDescriptionI"
                    ControlToValidate="txtMovieDescriptionI"
                    Text="(Required)"
                    Runat="server" /> 
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="Label9" runat="server" Text="Movie Duration"></asp:Label>
                </td>
                <td>
                    <asp:TextBox
                    id="txtMovieDurationI"
                    Runat="server" />
                </td>
                <td colspan ="2">
                     <asp:RequiredFieldValidator
                    id="reqMovieDurationI"
                    ControlToValidate="txtMovieDurationI"
                    Text="(Required)"
                    Runat="server" />  
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="Label10" runat="server" Text="Image Name"></asp:Label>
                </td>
                <td>
                    <asp:TextBox
                    id="txtimagefnameI"
                    Runat="server" />
                </td>
                <td colspan ="2">
                    <asp:RequiredFieldValidator
                    id="reqimagefnameI"
                    ControlToValidate="txtimagefnameI"
                    Text="(Required)"
                    Runat="server" />
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="Label11" runat="server" Text="Movie Rating"></asp:Label>
                </td>
                <td>
                  <asp:TextBox
                    id="txtRatingI"
                    Runat="server" />
                </td>
                <td colspan ="2">
                    <asp:RequiredFieldValidator
                    id="reqRatingI"
                    ControlToValidate="txtRatingI"
                    Text="(Required)"
                    Runat="server" />  
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="Label12" runat="server" Text="Trailers"></asp:Label>
                </td>
                <td>
                    <asp:TextBox
                    id="txtTrailersI"
                    Runat="server" />
                </td>
                <td colspan ="2">
                     <asp:RequiredFieldValidator
                    id="reqTrailersI"
                    ControlToValidate="txtTrailersI"
                    Text="(Required)"
                    Runat="server" />    
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="Label13" runat="server" Text="Theatre Release Date"></asp:Label>
                </td>
                <td>
                    <asp:TextBox
                    id="txtTheatreDateReleasedI"
                    Runat="server" />
                </td>
                <td>
                     <asp:RequiredFieldValidator
                    id="reqTheatreDateReleasedI"
                    ControlToValidate="txtTheatreDateReleasedI"
                    Text="(Required)"
                    Runat="server" /> 
                </td>
                <td>
                    <%--<asp:CompareValidator  ControlToValidate="txtTheatreDateReleasedI" Type="Date" Operator="DataTypeCheck" ID="CompareValidator1" runat="server" ErrorMessage="please enter date follow dd/mm/yyyy"></asp:CompareValidator>--%>
                     <asp:RegularExpressionValidator 
                     ID="RegularExpressionValidator1I" 
                     ControlToValidate="txtTheatreDateReleasedI" 
                     runat="server" 
                     ErrorMessage="(Please enter a valid date in the dd/MM/yyyy format)"
                      ValidationExpression="(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d">
                      </asp:RegularExpressionValidator>
                </td>
                </tr>
                <tr>
                <td>
                    <asp:Label ID="Label14" runat="server" Text="Main Cast"></asp:Label>
                </td>
                <td>
                    <asp:TextBox
                    id="txtMaincastI"
                    Runat="server" TextMode="MultiLine" />
                </td>
                <td colspan ="2">
                    <asp:RequiredFieldValidator
                    id="reqMaincastI"
                    ControlToValidate="txtMaincastI"
                    Text="(Required)"
                    Runat="server" /> 
                </td>
                </tr>
                </table>
                <table>
                <tr>
                <td>
                    
                    <asp:LinkButton ID="btnInsert" OnClick ="InsertMovie_Click" runat="server">Insert Movie</asp:LinkButton>
                </td>
                <td>
                    <asp:LinkButton ID="btnCancel" PostBackUrl="~/TheatreStaff/Movies.aspx" OnClick ="Cancel" CommandName="Cancel" CausesValidation ="false"  runat="server">Cancel</asp:LinkButton>
                </td>
                </tr>
            </table>
        </fieldset>
     <asp:SqlDataSource ID="srcMoviegrd" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        SelectCommand="SELECT Movie.MovieTitle, Movie.MovieId FROM Movie,TheatreStaff WHERE Movie.TheatreId=TheatreStaff.TheatreId 
        AND TheatreStaff.TheatreStaffUserName=@username"
        DeleteCommand ="DELETE Movie WHERE MovieId=@MovieId" >
            <SelectParameters>
                <asp:Parameter  Type="String"  Name="username" DefaultValue="adam" />
            </SelectParameters>
        </asp:SqlDataSource>
     
     
        <%--<asp:SqlDataSource ID="srcMoviegrd" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        SelectCommand="SELECT Movie.MovieTitle, Movie.MovieId, datesession.ticketsold FROM Movie INNER JOIN TheatreStaff ON Movie.TheatreId = TheatreStaff.TheatreId INNER JOIN datesession ON Movie.MovieId = datesession.movieid WHERE (TheatreStaff.TheatreStaffUserName = @username)"
        DeleteCommand ="DELETE Movie WHERE MovieId=@MovieId" >
            <SelectParameters>
                <asp:Parameter  Type="String"  Name="username" DefaultValue="adam" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="MovieId" />
            </DeleteParameters>
        </asp:SqlDataSource>--%>
        
        <asp:SqlDataSource ID="srcMovie" 
            SelectCommand ="SELECT Movie.MovieId,Movie.MovieTitle,Movie.MovieDirector,Movie.Showing,
            Movie.MovieDescription,Movie.TheatreId,Movie.MovieDuration,
            Movie.imagefname,Movie.Rating,Movie.Trailers,Movie.TheatreDateReleased,
            Movie.Maincast, Movie.CategoryID FROM Movie,TheatreStaff 
            Where Movie.TheatreId=TheatreStaff.TheatreId AND TheatreStaff.TheatreStaffUserName=@username 
            AND Movie.MovieId=@MovieId Order by Movie.MovieTitle" 
            InsertCommand="INSERT INTO Movie(MovieTitle,MovieDirector,Showing,
            MovieDescription,TheatreId,MovieDuration,
            imagefname,Rating,Trailers,TheatreDateReleased,
            Maincast,CategoryID)
            VALUES (@MovieTitle,@MovieDirector,@Showing,
            @MovieDescription,@TheatreId,@MovieDuration,
            @imagefname,@Rating,@Trailers,@TheatreDateReleased,
            @Maincast,@CategoryID)"
            UpdateCommand ="UPDATE Movie SET MovieTitle=@MovieTitle,MovieDirector=@MovieDirector,Showing=@Showing,
            MovieDescription=@MovieDescription,MovieDuration=@MovieDuration,
            imagefname=@imagefname,Rating=@Rating,Trailers=@Trailers,TheatreDateReleased=@TheatreDateReleased,
            Maincast=@Maincast,CategoryID=@CategoryID WHERE MovieId=@MovieId" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString %>"  runat="server" >
             <SelectParameters>
                  <asp:Parameter Name ="username" Type ="string"  /> 
                  <%-- <asp:ControlParameter Name ="MovieId" ControlID ="grdMovie" />--%>
             </SelectParameters>
             <InsertParameters >
                   <asp:Parameter Name="TheatreId" DbType="Int32"  />
            </InsertParameters>
            <UpdateParameters >
                   <asp:Parameter Name ="MovieId" DbType ="Int32" />
                   <asp:Parameter DbType ="String" Name ="MovieTitle" />
                   <asp:Parameter DbType ="String" Name ="MovieDirector" />
                   <asp:Parameter DbType ="Boolean" Name ="Showing" />
                   <asp:Parameter DbType ="String" Name ="MovieDescription" />
                   <asp:Parameter DbType ="String" Name ="MovieDuration" />
                   <asp:Parameter DbType ="String" Name ="imagefname" />
                   <asp:Parameter DbType ="String" Name ="Rating" />
                   <asp:Parameter DbType ="String" Name ="Trailers" />
                   <asp:Parameter DbType ="Date" Name ="TheatreDateReleased" />
                   <asp:Parameter DbType ="String" Name ="Maincast" />
                   <asp:Parameter DbType ="String" Name ="CategoryID" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="srcCategory" runat="server"  ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
            SelectCommand ="SELECT DISTINCT MovieCategory.MovieCategoryId,MovieCategory.MovieCategoryName FROM MovieCategory">
                <SelectParameters >
                    <asp:ControlParameter Name ="TheatreId" ControlID ="lblId"/>
                </SelectParameters>
            </asp:SqlDataSource>
            </div>
            </div>
       <br />     <br />   
  <table align="left"  cellpadding="15" ><tr><td>Copyright@2012 MovieTix</td><td><asp:HyperLink ID="HyperLink8"  CssClass="footer" NavigateUrl="~/Default.aspx" runat="server">Homepage</asp:HyperLink></td><td><asp:HyperLink ID="HyperLink9"  CssClass="footer" NavigateUrl="~/TheatreStaff/Session.aspx" runat="server">Session</asp:HyperLink></td><td><asp:HyperLink ID="HyperLink10"  CssClass="footer" NavigateUrl="~/TheatreStaff/Movies.aspx" runat="server">Movies</asp:HyperLink></td><td><asp:HyperLink ID="HyperLink12"  CssClass="footer" NavigateUrl="~/register.aspx" runat="server">Register</asp:HyperLink></td><td><asp:HyperLink ID="HyperLink13"  CssClass="footer" NavigateUrl="~/Login.aspx" runat="server">Log In</asp:HyperLink></td></tr></table>

   </div>
   
    </form>
    
</body>
</html>